﻿<%@ Page Title="<%$ Concat:UIStrings.DuplicateResources,' &raquo; ResourceBlender.NET' %>" Language="C#" MasterPageFile="~/Layout.master" AutoEventWireup="true" CodeFile="DuplicateResources.aspx.cs" Inherits="DuplicateResources" EnableEventValidation="false" ValidateRequest="false" %>
<%@ MasterType VirtualPath="~/Layout.master" %>
<%@ Register TagPrefix="L49" TagName="InlineNav" Src="~/InlineNav.ascx" %>

<asp:Content ID="cntHead" ContentPlaceHolderID="head" Runat="Server">
    <link rel="Stylesheet" type="text/css" href="css/spreadsheet.css" />
    <!--[if IE]>
    <link rel="Stylesheet" type="text/css" href="css/ie-spreadsheet.css" />
    <![endif]-->
</asp:Content>
<asp:Content ID="cntMain" ContentPlaceHolderID="cntMain" Runat="Server">
    <asp:ScriptManager ID="scrUpdateLanguages" runat="server"></asp:ScriptManager>
    <h1><asp:Literal runat="server" Text="<%$ Resources:UIStrings, DuplicateResources %>" /></h1>
    <div class="breadcrumbs">
        <asp:HyperLink ID="lnkNavHome" runat="server" NavigateUrl="~/Default.aspx">ResourceBlender.NET</asp:HyperLink> &gt; <asp:HyperLink ID="lnkNavResources" runat="server" NavigateUrl="~/ResourcesMain.aspx" Text="<%$ Resources:UIStrings, Resources %>"></asp:HyperLink> &gt; <asp:Literal runat="server" Text="<%$ Resources:UIStrings, DuplicateResources %>" />
    </div>
    <asp:MultiView ID="mltMain" runat="server" ActiveViewIndex="0">
        <asp:View ID="viwFindDuplicatesForm" runat="server">
            <div class="niceform">
                <fieldset>
                    <legend><asp:Literal runat="server" Text="<%$ Resources:UIStrings, FindDuplicates %>" /></legend>
                    <div class="formrow block">
                        <asp:UpdatePanel ID="updRadLanguage" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <div class="formrow block">
                                    <label class="block"><asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:UIStrings, Language %>" /></label>
                                    <asp:RadioButtonList ID="radLanguage" runat="server" RepeatLayout="Flow" 
                                        OnSelectedIndexChanged="SelectLanguage"
                                        AppendDataBoundItems="true"
                                        AutoPostBack="True" CssClass="checks applicationChecks plain" RepeatColumns="3">
                                    </asp:RadioButtonList>
                                    <asp:Button ID="btnRefresh" runat="server" Text="<%$ Resources:UIStrings, RefreshBundlesLanguages %>"
                                        OnClick="SelectLanguage" CssClass="uniformbutton doublewidth btnGo" />
                                </div>
                                <asp:UpdateProgress ID="prgRadLanguage" runat="server" 
                                    AssociatedUpdatePanelID="updRadLanguage" 
                                    DisplayAfter="100">
                                    <ProgressTemplate>
                                        <div class="centered"><asp:Image ID="imgLoadingLanguagesSelection" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="<%$ Resources:UIStrings, Loading %>" /></div>
                                    </ProgressTemplate>
                                </asp:UpdateProgress>
                                <asp:ObjectDataSource ID="dsMain" runat="server" TypeName="ResourceBlender.DAL.ResourceBlenderDAL" SelectMethod="GetDuplicateResourceCount" OnSelected="dsMain_Selected">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="radLanguage" PropertyName="SelectedValue" Name="languageCode" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                                <h3><asp:Literal ID="lblNumDuplicates" runat="server" Text="<%$ Resources:UIStrings, FindDuplicates %>" /></h3>
                                <asp:GridView ID="grdFindDuplicates" runat="server"
                                    AllowSorting="True" AutoGenerateColumns="false" CssClass="nicetable" 
                                    Width="100%" DataSourceID="dsMain" 
                                    OnRowCommand="grdFindDuplicates_RowCommand" 
                                    OnPageIndexChanging="grdFindDuplicates_PageIndexChanging" DataKeyNames="translation"
                                    PageSize="25">
                                    <PagerSettings PageButtonCount="8" Mode="NumericFirstLast" Position="TopAndBottom" />
                                    <Columns>
                                        <asp:TemplateField SortExpression="resource" HeaderText="<%$ Resources:UIStrings, Resource %>" ItemStyle-Width="80%">
                                            <ItemTemplate>
                                                <asp:Literal ID="lblTranslation" runat="server" Text='<%# Eval("translation") %>' EnableViewState="False" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField SortExpression="number" HeaderText="<%$ Resources:UIStrings, ResourcesWithIdenticalTranslations %>" ItemStyle-CssClass="centered">
                                            <ItemTemplate>
                                                <asp:Literal ID="lblNumDuplicates" runat="server" Text='<%# Eval("number") %>' EnableViewState="False" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="<%$ Resources:UIStrings, Details %>" ItemStyle-CssClass="singleButton">
                                            <ItemTemplate>
                                                <asp:UpdatePanel ID="updRadLanguage" runat="server" UpdateMode="Conditional">
                                                    <ContentTemplate>
                                                        <asp:ImageButton ID="btnViewDetails" runat="server" 
                                                            ToolTip='<%# ResourceBlender.Core.I18nUtils.GetString("UIStrings", "ViewDetailsForResource", Eval("resourceid").ToString()) %>'
                                                            CommandName="viewdetails"
                                                            CommandArgument='<%# Eval("resourceid") %>'
                                                            ImageUrl="~/images/upload.png" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:PostBackTrigger ControlID="btnViewDetails" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <HeaderStyle CssClass="excelHead" />
                                    <AlternatingRowStyle CssClass="alt" />
                                </asp:GridView>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="radLanguage"
                                    EventName="SelectedIndexChanged" />
                            </Triggers>
                        </asp:UpdatePanel>
                    </div>
                </fieldset>
            </div>
        </asp:View>
        <asp:View ID="viwFindDuplicates" runat="server">
            <asp:ObjectDataSource ID="dsDuplicateDetails" runat="server" TypeName="ResourceBlender.DAL.ResourceBlenderDAL" SelectMethod="GetDuplicateResources">
                <SelectParameters>
                    <asp:Parameter Name="languages" Type="Object" />
                    <asp:ControlParameter ControlID="radLanguage" PropertyName="SelectedValue" Name="resourceLanguage" />
                    <asp:ControlParameter ControlID="grdFindDuplicates" PropertyName="SelectedDataKey[0]" Name="resourceTranslation" Type="String" />
                    <%-- %>asp:Parameter Name="resourceTranslation" Type="String" /--%>
                </SelectParameters>
            </asp:ObjectDataSource>
            <asp:ObjectDataSource ID="dsResourceIDs" runat="server" TypeName="ResourceBlender.DAL.ResourceBlenderDAL" SelectMethod="GetResourcesTrimmed">
                <SelectParameters>
                    <asp:ControlParameter ControlID="radLanguage" PropertyName="SelectedValue" Name="language" />
                    <asp:Parameter Name="numCharacters" Type="Int32" DefaultValue="15" />
                    <asp:Parameter Name="trimUsingSql" Type="Boolean" DefaultValue="true" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <div id="fullsizeholder" class="ssFullSize" runat="server">
                <h1><asp:Literal runat="server" Text="<%$ Resources:UIStrings, DuplicateResources %>" /></h1>
                <div class="breadcrumbs">
                    <asp:HyperLink ID="lnkNavHomeFull" runat="server" NavigateUrl="~/Default.aspx">ResourceBlender.NET</asp:HyperLink> &gt; <asp:HyperLink ID="lnkNavResourcesFull" runat="server" NavigateUrl="~/ResourcesMain.aspx" Text="<%$ Resources:UIStrings, Resources %>"/> &gt; <asp:LinkButton ID="lnkNavDuplicateResources" runat="server" OnClick="lnkNavDuplicateResources_Click" Text="<%$ Resources:UIStrings, DuplicateResources %>" /> &gt; <asp:Literal ID="Literal4" runat="server" Text="<%$ Resources:UIStrings, EditDuplicateResource %>" />
                </div>
                <div style="float:left">
                    <asp:UpdateProgress ID="upgGrdResources" runat="server" 
                        AssociatedUpdatePanelID="updGrdResources" 
                        DisplayAfter="100">
                        <ProgressTemplate>
                            <div class="centered"><asp:Image ID="imgLoadingResource" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="<%$ Resources:UIStrings, Loading %>" /></div>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </div>
                <div id="inlinenav">
                    <asp:LinkButton ID="lnkExpandScreen" runat="server" CssClass="lnkContract" 
                        OnClientClick="return toggleFullWindow(this);" 
                        onclick="lnkExpandScreen_Click" CausesValidation="False" 
                        EnableViewState="False" Text="<%$ Resources:UIStrings, ContractNormalSize %>"></asp:LinkButton>
                    <L49:InlineNav runat="server" />
                </div>
                <div class="clear"></div>
                <asp:UpdatePanel ID="updGrdResources" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:GridView ID="grdDuplicateDetail" runat="server" AllowPaging="True" 
                            AllowSorting="True" AutoGenerateColumns="true" CssClass="nicetable" SelectedRowStyle-CssClass="ssRowSelected"
                            Width="100%" DataSourceID="dsDuplicateDetails"
                            OnRowDatabound="grdDuplicateDetail_RowDataBound" 
                            OnRowCommand="grdDuplicateDetail_RowCommand" 
                            OnPageIndexChanging="grdDuplicateDetail_PageIndexChanging"
                            OnPreRender="grdDuplicateDetail_PreRender"
                            PageSize="15">
                            <PagerSettings PageButtonCount="8" Mode="NumericFirstLast" Position="TopAndBottom" />
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <%# Container.DataItemIndex +1 %>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ssRowLabel" HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="<%$ Resources:UIStrings, ID %>">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkSelect" runat="server" Text='<%# Eval("tid") %>' ToolTip='<%# ResourceBlender.Core.I18nUtils.GetString("UIStrings", "SelectTranslationNum", Eval("tid").ToString()) %>'  />
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ssCell" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="<%$ Resources:UIStrings, UsedBy %>" SortExpression="numelements">
                                    <ItemTemplate>
                                        <asp:Label ID="lblUsedBy" runat="server" Text='<%# ResourceBlender.Core.I18nUtils.GetString("UIStrings", "ElementsNum",Eval("numelements").ToString()) %>' EnableViewState="False" ToolTip='<%# ResourceBlender.Core.I18nUtils.GetString("UIStrings", "ElementsUseThisResourceNum",Eval("numelements").ToString()) %>'></asp:Label>
                                        <asp:ImageButton ID="imgShowDetails" runat="server" ImageUrl="~/images/arrow_down.gif" ToolTip="<%$ Resources:UIStrings, ShowElements %>" CommandName="showelements" CommandArgument="1" ></asp:ImageButton>
                                        <asp:Panel ID="pnlElementDetail" runat="server" Visible="false" CssClass="elementDetail">
                                        </asp:Panel>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ssCell" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="<%$ Resources:UIStrings, Edit %>">
                                    <ItemTemplate>
                                        <asp:MultiView ID="mltActions" runat="server" ActiveViewIndex="0">
                                            <asp:View ID="viwEdit" runat="server">
                                                <div class="centered">
                                                    <asp:ImageButton ID="btnEdit" runat="server" 
                                                        ToolTip='<%# ResourceBlender.Core.I18nUtils.GetString("UIStrings", "EditResourceNum", Eval("tid").ToString()) %>' 
                                                        EnableViewState="False"
                                                        CommandName="editresource" 
                                                        ImageUrl="~/images/edit.png" />
                                                    <asp:ImageButton ID="btnDelete" runat="server" 
                                                        ToolTip='<%# ResourceBlender.Core.I18nUtils.GetString("UIStrings", "DeleteResourceNum", Eval("tid").ToString()) %>' 
                                                        CommandName="deleteresource" 
                                                        CommandArgument='<%# Eval("tid") %>'
                                                        ImageUrl="~/images/delete.png" />
                                                </div>
                                            </asp:View>
                                            <asp:View ID="viwConfirmDelete" runat="server">
                                                <div class="centered">
                                                    <asp:Label ID="lblConfirmDelete" runat="server" Text='<%# ResourceBlender.Core.I18nUtils.GetString("UIStrings", "DeleteResourceNumPrompt",Eval("tid").ToString()) %>' CssClass="block"></asp:Label>
                                                    <asp:Button ID="btnConfirmDelete" runat="server" Text="<%$ Resources:UIStrings, Delete %>" CommandName="confirmdelete" CommandArgument='<%# Eval("tid") %>' ValidationGroup="deleteresource" CssClass="uniformbutton btnConfirm" />
                                                    <asp:Button ID="btnCancelDelete" runat="server" Text="<%$ Resources:UIStrings, Cancel %>" CommandName="canceledit" ValidationGroup="deleteresource" CssClass="uniformbutton btnCancel" />
                                                </div>
                                            </asp:View>
                                        </asp:MultiView>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:Label ID="lblResourceIdDesc" runat="server" EnableViewState="False" AssociatedControlID="cboResourceID" CssClass="block"></asp:Label><%-- formatted - Reassign x elements to resource --%>
                                        <asp:DropDownList ID="cboResourceID" runat="server" ValidationGroup="editelement" CssClass="block" OnSelectedIndexChanged="cboResourceID_SelectedIndexChanged" DataSourceID="dsResourceIDs" DataTextField="Value" DataValueField="Key">
                                        </asp:DropDownList>
                                        <asp:Button ID="btnChangeResource"  Visible="false" runat="server" Text="<%$ Resources:UIStrings, ChangeResource %>" CommandName="changeresource" EnableViewState="False" />
                                        <asp:Label ID="lblError" runat="server" CssClass="block error"></asp:Label>
                                        <asp:Label ID="lblResourceComment" runat="server" Text="<%$ Resources:UIStrings, Comment %>" AssociatedControlID="txtResourceComment" EnableViewState="False" CssClass="block"></asp:Label>
                                        <asp:TextBox ID="txtResourceComment" runat="server" Text='<%# Eval("resourcecomment") %>' TextMode="MultiLine" EnableViewState="False" ValidationGroup="editresource" CssClass="block"></asp:TextBox>
                                        <asp:Button ID="btnDeleteResource" runat="server" Text="<%$ Resources:UIStrings, DeleteResource %>" CommandName="deleteresource" CommandArgument='<%# Eval("tid") %>' ValidationGroup="editresource" CssClass="block uniformbutton btnDelete doublewidth" />
                                        <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:UIStrings, Save %>" CommandName="saveresource" CommandArgument='<%# Eval("tid") %>' ValidationGroup="editresource" CssClass="uniformbutton btnSave" />
                                        <asp:Button ID="btnCancel" runat="server" Text="<%$ Resources:UIStrings, Cancel %>" CommandName="canceledit" ValidationGroup="editresource" CssClass="uniformbutton btnCancel" />
                                    </EditItemTemplate>
                                    <ItemStyle CssClass="ssCell" />
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle CssClass="excelHead" />
                            <RowStyle CssClass="even" />
                            <AlternatingRowStyle CssClass="alt" />
                            <PagerStyle CssClass="pager" />
                            <EmptyDataTemplate>
                                <p><asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:UIStrings, InvalidResource %>" /></p>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <div class="niceform">
                    <fieldset>
                        <legend><asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:UIStrings, Options %>" /></legend>
                        <div class="formrow block">
                            <asp:Label ID="lblPreferredResource" runat="server" Text="<%$ Resources:UIStrings, PreferredResource %>" AssociatedControlID="cboPreferredResource" />
                            <asp:DropDownList ID="cboPreferredResource" runat="server" DataSourceID="dsDuplicateDetails" DataTextField="tid" DataValueField="tid"/>
                        </div>
                        <div class="formrow block">
                            <asp:CheckBox ID="chkDeleteUnusedResources" runat="server" Text="<%$ Resources:UIStrings, DeleteUnusedResourcesAfterMerge %>" />
                        </div>
                      </fieldset>
                    </div>
                    <div class="actions">
                        <div class="formrow block">
                            <asp:Button ID="btnSelectAll" runat="server" Text="<%$ Resources:UIStrings, SelectAll %>" OnClick="btnSelectAll_Click" OnPreRender="btnSelectAll_PreRender" CssClass="uniformbutton" />
                            <asp:Button ID="btnMerge" runat="server" Text="<%$ Resources:UIStrings, MergeTranslations %>" OnClick="btnMerge_Click" CssClass="uniformbutton doublewidth btnGo" />
                        </div>
                        <asp:Label ID="lblMergeError" runat="server" CssClass="error"></asp:Label>
                    </div>
            </div><!-- end fullsizeholder -->
        </asp:View>
        <asp:View ID="viwMergeResults" runat="server">
            <asp:PlaceHolder ID="plcResults" runat="server"></asp:PlaceHolder>
        </asp:View>
    </asp:MultiView>
</asp:Content>

